import unittest
from appium import webdriver
from Public.Desired_Config import desired
from Page.mainPage import mainPage
from Page.myPage import myPage
from testData.data import Data
from Page.public import public
from Page.loginPage import loginPage
from Page.changeLocation import changeLocation
import time

class Test_Index(unittest.TestCase):
    def setUp(self):
        self.driver =webdriver.Remote("http://localhost:4723/wd/hub",desired())
        self.mainPage = mainPage(self.driver)
        self.myPage = myPage(self.driver)
        self.data = Data()
        self.public =public(self.driver)
        self.loginPage = loginPage(self.driver)
        self.changeLocation= changeLocation(self.driver)
    def tearDown(self):
        self.driver.quit()
    #验证推荐栏位
    def test01(self):
        time.sleep(3)
        self.assertEqual(self.mainPage.workDevelopmentTab().text,"职场发展")
        self.assertEqual(self.mainPage.industryTab().text,"行业经验")
        self.assertEqual(self.mainPage.internetTab().text,"互联网")
        self.assertEqual(self.mainPage.heartTab().text,"心理")
        self.assertEqual(self.mainPage.lifeTab().text,"生活服务")
        self.assertEqual(self.mainPage.startTab().text,"创业和投融资")
        self.assertEqual(self.mainPage.studyTab().text,"教育学习")
        self.assertEqual(self.mainPage.allTab().text,"全部分类")
    #点击消息中心，跳转到提示登录页面
    def test02(self):
        time.sleep(2)
        self.mainPage.noticeTab().click()
        time.sleep(3)
        self.assertEqual(self.loginPage.loginControl().text,"微信登录")
    #点击我的，跳转到提示登录页面
    def test03(self):
        time.sleep(2)
        self.mainPage.myTab().click()
        time.sleep(2)
        self.assertEqual(self.loginPage.login().text,"立即登录")
    #点击切换城市，跳转到切换城市页面
    def test04(self):
        time.sleep(2)
        self.mainPage.locationTab().click()
        time.sleep(2)
        self.assertEqual(self.changeLocation.relocationTab().text,"重新定位")
    #点击切换城市，跳转到切换城市页面，并切换城市
    def test05(self):
        time.sleep(2)
        self.mainPage.locationTab().click()
        time.sleep(2)
        self.changeLocation.cityTab().click()
        time.sleep(2)
        self.assertEqual(self.mainPage.locationTab().text,'北京')
if __name__ =='__main__':
    suite = unittest.TestLoader.loadTestsFromTestCase(Test_Index)
    unittest.TextTestRunner().run(suite)
